<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class GoodsUpdateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'goods_name' => 'required',
            'goods_price' => 'required|numeric|min:0.1',
            'rebate' => 'required|numeric|min:1|max:10',
            'goods_stock' => 'required|numeric|min:1',
            'goods_content' => 'required',
        ];
    }

    /*
        提示中文错误信息
    */
    public function messages()
    {
        return [
            'goods_name.required' => '商品名称不能为空',
            'goods_price.required' => '商品价格不能为空',
            'goods_price.numeric' => '商品价格只能数字',
            'goods_price.min' => '商品价格不能小于0.1',
            'rebate.required' => '商品折扣不能为空',
            'rebate.numeric' => '商品折扣只能为数字',
            'rebate.min' => '商品折扣应该为1-10',
            'rebate.max' => '商品折扣应该为1-10',
            'goods_stock.required' => '商品库存不能为空',
            'goods_stock.numeric' => '商品库存只能为数字',
            'goods_stock.min' => '商品库存不小于1',
            'goods_content.required' => '商品描述不能为空',
        ];
    }
}
